package com.athuiju.hr.service.impl;

import com.alibaba.nacos.client.utils.StringUtils;
import com.athuiju.hr.entity.Administrator;
import com.athuiju.hr.entity.vo.AdministratorVo;
import com.athuiju.hr.entity.vo.AdministratorVoQuery;
import com.athuiju.hr.entity.vo.ProRessultVo;
import com.athuiju.hr.mapper.AdministratorMapper;
import com.athuiju.hr.service.AdministratorService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wzh
 * @since 2022-01-12
 */
@Service
public class AdministratorServiceImpl extends ServiceImpl<AdministratorMapper, Administrator> implements AdministratorService {
@Autowired
AdministratorMapper administratorMapper;

    @Override
    public void pageQuery(Page<AdministratorVo> pageSture, AdministratorVoQuery administratorVoQuery) {
        QueryWrapper<AdministratorVo> queryWrapper=new QueryWrapper<>();
        //当模糊查询条件为null时，就显示pageSture里面的所有数据
        if (administratorVoQuery== null) {
            baseMapper.selectMyPageAdmin(pageSture,null);
            return;
        }
        String name=administratorVoQuery.getName();
        String begin = administratorVoQuery.getBegin();
        String end = administratorVoQuery.getEnd();
        String number = administratorVoQuery.getNumber();
        //根据姓名查询
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("administrator.name",name);
        }//根据电话模糊查询
        if (!StringUtils.isEmpty(number)){
            queryWrapper.like("administrator.number",number);
        }//根据创建时间降序排列
        queryWrapper.orderByDesc("administrator.gmt_create");
        baseMapper.selectMyPageAdmin(pageSture,queryWrapper);
    }
}
